home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / fsinstall / RCS / diskPrint.c,v < prev    next >
Encoding:
Text File  |  1990-01-31  |  5.8 KB  |  236 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     90.01.31.13.54.13;  author shirriff;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @File as of 1-31-90, before replaced by symbolic link.
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/* 
  27.  * diskPrint.c --
  28.  *
  29.  *    Routines to print out data structures found on the disk.
  30.  *
  31.  * Copyright (C) 1987 Regents of the University of California
  32.  * All rights reserved.
  33.  * Permission to use, copy, modify, and distribute this
  34.  * software and its documentation for any purpose and without
  35.  * fee is hereby granted, provided that the above copyright
  36.  * notice appear in all copies.  The University of California
  37.  * makes no representations about the suitability of this
  38.  * software for any purpose.  It is provided "as is" without
  39.  * express or implied warranty.
  40.  */
  41.  
  42. #ifndef lint
  43. static char rcsid[] = "$Header: /sprite/src/lib/c/disk/RCS/diskPrint.c,v 1.3 89/09/25 12:32:37 jhh Exp $ SPRITE (Berkeley)";
  44. #endif not lint
  45.  
  46. #include <stdio.h> 
  47. #include "diskUtils.h"
  48.  
  49.  
  50. /*
  51.  *----------------------------------------------------------------------
  52.  *
  53.  * Disk_PrintDomainHeader --
  54.  *
  55.  *    Print out the domain header.  Used in testing.
  56.  *
  57.  * Results:
  58.  *    None.
  59.  *
  60.  * Side effects:
  61.  *    None.
  62.  *
  63.  *----------------------------------------------------------------------
  64.  */
  65. void
  66. Disk_PrintDomainHeader(headerPtr)
  67.     register Fsdm_DomainHeader *headerPtr;/* Reference to domain header to print*/
  68. {
  69.     register Fsdm_Geometry *geoPtr;
  70.     register int    index;
  71.  
  72.     printf("Domain Header <%x>\n", headerPtr->magic);
  73.     printf("First Cyl %d, num Cyls %d", headerPtr->firstCylinder,
  74.             headerPtr->numCylinders);
  75.     printf(", raw size %d kbytes\n", headerPtr->numCylinders *
  76.         headerPtr->geometry.sectorsPerTrack *
  77.         headerPtr->geometry.numHeads / 2);
  78.     printf("%-20s %10s %10s\n", "", "offset", "blocks");
  79.     printf("%-20s %10d %10d\n", "FD Bitmap", headerPtr->fdBitmapOffset,
  80.             headerPtr->fdBitmapBlocks);
  81.     printf("%-20s %10d %10d %10d\n", "File Desc", headerPtr->fileDescOffset,
  82.             headerPtr->numFileDesc/FSDM_FILE_DESC_PER_BLOCK,
  83.             headerPtr->numFileDesc);
  84.     printf("%-20s %10d %10d\n", "Bitmap", headerPtr->bitmapOffset,
  85.             headerPtr->bitmapBlocks);
  86.     printf("%-20s %10d %10d\n", "Data Blocks", headerPtr->dataOffset,
  87.             headerPtr->dataBlocks);
  88.     geoPtr = &headerPtr->geometry;
  89.     printf("Geometry\n");
  90.     printf("sectorsPerTrack %d, numHeads %d\n", geoPtr->sectorsPerTrack,
  91.                   geoPtr->numHeads);
  92.     printf("blocksPerRotSet %d, tracksPerRotSet %d\n",
  93.                geoPtr->blocksPerRotSet, geoPtr->tracksPerRotSet);
  94.     printf("rotSetsPerCyl %d, blocksPerCylinder %d\n",
  95.                geoPtr->rotSetsPerCyl, geoPtr->blocksPerCylinder);
  96.     printf("Offset    (Sorted)\n");
  97.     for (index = 0 ; index < geoPtr->blocksPerRotSet ; index++) {
  98.     printf("%8d %8d\n", geoPtr->blockOffset[index],
  99.                geoPtr->sortedOffsets[index]);
  100.     }
  101.  
  102.     printf(">> %d files, %d kbytes\n", headerPtr->numFileDesc,
  103.         headerPtr->dataBlocks * 4);
  104. }
  105.  
  106. /*
  107.  *----------------------------------------------------------------------
  108.  *
  109.  * Disk_PrintSummaryInfo --
  110.  *
  111.  *    Print out the summary information.
  112.  *
  113.  * Results:
  114.  *    None.
  115.  *
  116.  * Side effects:
  117.  *    None.
  118.  *
  119.  *----------------------------------------------------------------------
  120.  */
  121. void
  122. Disk_PrintSummaryInfo(summaryPtr)
  123.     register Fsdm_SummaryInfo *summaryPtr; /* Reference to summary info to print */
  124. {
  125.     printf("\"%s\"\t%d Kbytes free, %d file descriptors free\n",
  126.         summaryPtr->domainPrefix, summaryPtr->numFreeKbytes,
  127.         summaryPtr->numFreeFileDesc);
  128. }
  129.  
  130. /*
  131.  *----------------------------------------------------------------------
  132.  *
  133.  * Disk_PrintFileDescBitmap --
  134.  *
  135.  *    Print out the file descriptor bitmap.
  136.  *
  137.  * Results:
  138.  *    None.
  139.  *
  140.  * Side effects:
  141.  *    None.
  142.  *
  143.  *----------------------------------------------------------------------
  144.  */
  145. void
  146. Disk_PrintFileDescBitmap(headerPtr, bitmap)
  147.     Fsdm_DomainHeader    *headerPtr;    /* Pointer to disk header info. */
  148.     char        *bitmap;    /* Pointer to file desc bit map. */
  149. {
  150.     register int index;
  151.  
  152.     printf("File Descriptor bitmap\n");
  153.     for (index = 0;
  154.      index < headerPtr->fdBitmapBlocks * FS_BLOCK_SIZE;) {
  155.     if ((index % 32) == 0) {
  156.         printf("%6d ", index * BITS_PER_BYTE);
  157.         if (index * BITS_PER_BYTE > headerPtr->numFileDesc) {
  158.         printf(" (The rest of the map is not used)\n");
  159.         break;
  160.         }
  161.     }
  162.     printf("%02x", bitmap[index] & 0xff);
  163.     index++;
  164.     if ((index % 32) == 0) {
  165.         printf("\n");
  166.     }
  167.     }
  168. }
  169.  
  170. /*
  171.  *----------------------------------------------------------------------
  172.  *
  173.  * Disk_PrintDataBlockBitmap --
  174.  *
  175.  *    Print out the data block bitmap.
  176.  *
  177.  * Results:
  178.  *    None.
  179.  *
  180.  * Side effects:
  181.  *    None.
  182.  *
  183.  *----------------------------------------------------------------------
  184.  */
  185. void
  186. Disk_PrintDataBlockBitmap(headerPtr, bitmap)
  187.     Fsdm_DomainHeader    *headerPtr;    /* Ptr to disk header info. */
  188.     char        *bitmap;    /* Ptr to data block bit map. */
  189. {
  190.     register int index;
  191.  
  192.     printf("Data block bitmap:\n");
  193.     for (index = 0;
  194.      index < headerPtr->bitmapBlocks * FS_BLOCK_SIZE;) {
  195.     if ((index % 32) == 0) {
  196.         printf("%6d ", index * BITS_PER_BYTE);
  197.         if (index * BITS_PER_BYTE >
  198.         headerPtr->dataBlocks * DISK_KBYTES_PER_BLOCK) {
  199.         printf(" (The rest of the bitmap is not used)\n");
  200.         break;
  201.         }
  202.     }
  203.     printf("%02x", bitmap[index] & 0xff);
  204.     index++;
  205.     if ((index % 32) == 0) {
  206.         printf("\n");
  207.     }
  208.     }
  209. }
  210.  
  211. /*
  212.  *----------------------------------------------------------------------
  213.  *
  214.  * Disk_PrintDirEntry --
  215.  *
  216.  *    Print out one directory entry
  217.  *
  218.  * Results:
  219.  *    None.
  220.  *
  221.  * Side effects:
  222.  *    None.
  223.  *
  224.  *----------------------------------------------------------------------
  225.  */
  226. void
  227. Disk_PrintDirEntry(dirEntryPtr)
  228.     Fslcl_DirEntry *dirEntryPtr;    /* Ptr to directory entry. */
  229. {
  230.     printf("\"%-15s\", File Number = %d, Rec Len = %d, Name Len = %d\n",
  231.            dirEntryPtr->fileName, dirEntryPtr->fileNumber,
  232.            dirEntryPtr->recordLength, dirEntryPtr->nameLength);
  233. }
  234.  
  235. @
  236.